# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Simon Sapin <simon dot sapin at exyr dot org>
# Contributor: Kyle Keen <keenerd@gmail.com>

pkgname=python-flasgger
pkgver=0.9.5
pkgrel=8
pkgdesc="Extract swagger specs from your flask project"
url="https://github.com/flasgger/flasgger"
license=('MIT')
arch=('any')
depends=('python-flask' 'python-yaml' 'python-jsonschema' 'python-mistune' 'python-six')
makedepends=('python-setuptools')
checkdepends=('python-pytest' 'python-flex' 'python-marshmallow' 'python-decorator'
              'python-apispec-webframeworks' 'python-flask-restful' 'python-flask-jwt')
source=("$pkgname-$pkgver.tar.gz::https://github.com/flasgger/flasgger/archive/$pkgver.tar.gz"
        $pkgname-werkzeug-safe_str_cmp.patch::https://github.com/flasgger/flasgger/pull/532.patch
        $pkgname-apispec-4.patch::https://github.com/flasgger/flasgger/pull/440.patch)
sha512sums=('d785c272a3d2fc4753ceb061587fff1db2ec726fe7cea7b0ec723a56f2f1f6296545f52249a08a1ae042e2c002c88eb2d9442928c53b00345bdde82442149fae'
            '2f07f5704128cf80892a2515bef34d3eb1bc15ff75229df79fdd4b28912ecb384f68e6f7a4079278e91412ba20ed3d1124b1356dde1dbeeeab133b9508130ca8'
            '090e16e0591ad1fccb028d92cd50256705d624a3a86812a0d4461834f941796dc53138612c6a743d15d9562931b8d51dbfc4bd7cdb0528326a4769ab5c909197')

prepare() {
  cd flasgger-$pkgver
  patch -p1 -i ../$pkgname-apispec-4.patch
  patch -p1 -i ../$pkgname-werkzeug-safe_str_cmp.patch
}

build() {
  cd flasgger-$pkgver
  python setup.py build
}

check() {
  cd flasgger-$pkgver
  PYTHONPATH="$PWD/etc/flasgger_package" python -m pytest tests
}

package() {
  cd flasgger-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
}
